home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / lcppb.zip / LCPP05.ZIP / ELEVSIM.H < prev    next >
C/C++ Source or Header  |  1990-12-05  |  3KB  |  66 lines

  1. // elevsim.h -- General header file for elevator simulation
  2.  
  3. #ifndef __ELEVSIM_H
  4. #define __ELEVSIM_H     1     // Prevent multiple #includes
  5.  
  6. /* -- Various constants. Don't change these. */
  7.  
  8. #define FALSE 0         // Value meaning false
  9. #define TRUE 1          // Value meaning true
  10. #define UP 1            // Value for direction == up
  11. #define DOWN -1         // Value for direction == down
  12. #define NODIRECTION 0   // Value for direction == none
  13. #define ESCKEY 27       // ASCII value for <Esc> key
  14.  
  15. /* -- Other constants. Okay to change with care. MAXPERSONS is
  16. limited by available memory--you may not be able to increase this
  17. value much beyond 1000 or so. Also, be sure to keep MAXELEVS and
  18. MAXFLOORS within the ranges stated in the comments below. Values
  19. outside of these ranges may work, but too many floors or elevators 
  20. will turn the simulation's display to mush. */
  21.  
  22. #define MAXELEVS 10     // Number of elevators (1 to 10 only)
  23. #define MAXFLOORS 10    // Number of floors (2 to 10 only)
  24. #define MAXPERSONS 500  // Maximum people in building
  25. #define ELEVWAIT 15     // Min. seconds to wait at floors
  26. #define CAPACITY 24     // Maximum people in an elevator
  27. #define TRAVELTIME 5    // Seconds to travel between floors
  28.  
  29. /* -- Formulas using rand() function to make various decisions.  Feel
  30. free adjust these values to alter the simulation. WANTS_TO_ENTER
  31. controls how frequently people enter the building. ENTER_DEST selects
  32. the destination floor which must be within 1 to MAXFLOORS - 1.
  33. MAX_WAIT determines how many seconds a person will wait for an
  34. elevator before getting fed up and taking the stairs. BUSINESS
  35. controls how many seconds people spend at their destination floors
  36. before going elsewhere or leaving the building. LEAVING controls
  37. whether a person will leave or go to another floor--it's currently
  38. set to force people to decide to leave about 2/3 the time. */
  39.  
  40. #define WANTS_TO_ENTER  rand() < 200
  41. #define ENTER_DEST      1 + (rand() % (MAXFLOORS - 1))
  42. #define MAX_WAIT        180 + (rand() % 180)
  43. #define BUSINESS        400 + (rand() % 6200)
  44. #define LEAVING         rand() < 22000
  45.  
  46. /* -- Global variable declarations. These variables are defined in
  47. elevsim.cpp and are the only global variables in the program except
  48. for the building object (see elevsim.cpp). The program uses these
  49. values to display the simulation statistics on the bottom line. All
  50. other program variables are class variables or are local to class
  51. functions. */
  52.  
  53. extern unsigned totalPeople;     // Number of people handled
  54. extern unsigned inBuilding;      // People in building now
  55. extern unsigned leftBuilding;    // People who left building
  56. extern unsigned avgWait;         // Average no. people waiting
  57. extern unsigned avgRide;         // Average no. people in elevators
  58. extern unsigned tookStair;       // Number people who walked
  59. extern unsigned totalTime;       // Seconds simulation has run
  60.  
  61. #endif   // __ELEVSIM_H
  62.  
  63.  
  64. // Copyright (c) 1990 by Tom Swan. All rights reserved
  65. // Revision 1.00   Date: 09/18/1990   Time: 09:20 am
  66.